package com.wicket.okrobff.plugin.config;

import com.wicket.okrobff.plugin.interceptor.AuthInterceptor;
import com.wicket.okrobff.plugin.interceptor.CommonInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @author ：CHS
 * @since 2022/3/29 17:24
 *
 *
 * @version 1.0
 */
@Configuration
public class CustomWebMvcConfigurer implements WebMvcConfigurer {

    @Bean
    public AuthInterceptor myInterceptor() {
        return new AuthInterceptor();
    }

    @Bean
    public CommonInterceptor myInterceptor2() {
        return new CommonInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(myInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/**/oms/mgt/security/implementBrushSoftwareAuthorization","/**/oms/base/querySpaceAppDetailCom", "/**/oms/user/login", "/**/oms/common/setpublicinfo", "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**",
                        "/api", "/api-docs", "/api-docs/**", "/doc.html/**", "/error", "/favicon.ico");

        registry.addInterceptor(myInterceptor2()).addPathPatterns("/**/oms/base/querySpaceAppDetailCom", "/**/oms/user/login");
    }

}
